# -*- coding:utf-8 -*-
# -------------------------------------------------------------------------------
# Description:  
# Reference:
# Author: 安智军
# Date:   2021/11/17
# -------------------------------------------------------------------------------
import time
from PageLocators.PageLoginLoc import LoginPageLoc as loc
from Common.Base import Base
from Common.GetLog import GetLog

log = GetLog.get_logger()


class wms_login(Base):

    def page_input_username(self, username):
        '''
        输入用户名
        :param username:
        :return:
        '''
        log.info("登录页输入账号")
        self.base_input(loc.login_username,username)

    def page_input_password(self, password):
        '''
        输入密码
        :param username:
        :return:
        '''
        log.info("登录页输入账号")
        self.base_input(loc.login_password, password)

    def page_click_login_btn(self):
        '''
        点击登录按钮
        :return:
        '''
        log.info("登录页点击登录按钮")
        self.base_click(loc.login_btn)

    def page_get_login_success_text(self):
        '''
        获取登录成功文本信息。用来做断言
        :return: 返回登录失败文本信息
        '''
        log.info("获取登录成功文本信息")
        time.sleep(3)
        return self.base_get_element_text(loc.login_success_text)

    # def page_get_login_failure_text(self):
    #     '''
    #     获取登录失败文本信息、用来做断言
    #     :return: 返回登录失败文本信息
    #     '''
    #     log.info("获取登录失败文本信息")
    #     return self.base_get_element_text(loc.login_failure_text)

    def page_login(self, username, password):
        '''
        登录页综合业务封装
        :param mobile: 用户名就是手机号
        :param verify_code: 验证码
        :param password: 密码
        :return:
        '''
        time.sleep(1)
        self.page_input_username(username)
        self.page_input_password(password)
        self.page_click_login_btn()

    def page_get_cookies(self,driver):
        '''
        获取cookies
        :return: cookies
        '''
        return driver.get_cookies()